/**
 * 对表单进行重新封装，简化表单参数
 */
var customTable=function (data) {
    if (isEmpty(data.sidePagination)) {
        data.sidePagination = "server";
    }
    if (isEmpty(data.sidePagination)) {
        data.pagination = true;         //开启分页
    }
    if (isEmpty(data.pageNumber)) {
        data.pageNumber = 1;
    }
    if (isEmpty(data.pageSize)) {
        data.pageSize = 10;
    }
    if (isEmpty(data.pageList)) {
        data.pageList = [5, 10, 25, 50, 100];
    }
    if (isEmpty(data.onLoadSuccess)) {
        data.onLoadSuccess = function() {
            $("[data-toggle='tooltip']").tooltip();
        }
    }
    data.queryParams = function (params) {
        params.pageSize = params.limit;
        params.pageNum = (params.offset / params.limit) + 1;
        Object.assign(params, data.where);
        return params;
    }

    $(data.container).bootstrapTable(data);
}

/**
 * 验证数据是否为空
 */
function isEmpty(param) {
    if (param == null || param == '') {
        return false;
    }
    return true;
}

/**
 * 验证数据是否非空
 */
function isNotEmpty(param) {
    if (param == null || param == '') {
        return true;
    }
    return false;
}

/**
 * 获取表单元素
 */
function getParams(label) {
    var field = {};
    $(label + " input[type='text']").each(function(j,item){
        field[item.name]=item.value;
    });
    $(label + " input[type='hidden']").each(function(j,item){
        field[item.name]=item.value;
    });
    return field;
}

/**
 * 清除表单元素
 */
function reset(label) {
    $(label + " :input").val("")
        .removeAttr("checked")
        .removeAttr("selected");
}